

from time import time
from functools import wraps



def time_decorator(func):
    @wraps(func)
    def wrapper(*args, **kargs):
        start_time = time()

        result = func(*args, **kargs)

        end_time = time()
        print(f"{func.__name__}执行时间：{end_time - start_time:.4f} s")
        return result
    return wrapper


@time_decorator
def main():

    n = 1_000_000_000_004
    k = 1_000_000_000_002

    while k > 0 and n != 1:
        # 偶数
        if (n & 1) == 0:
            # 找到是 2 的 几次方
            # 二进制， -n 是 n 的补码 得到n的最大偶数因数
            # print(n & -n)
            tz = (n & -n).bit_length() - 1

            t = min(k, tz)
            n >>= t
            k -= t

        else:
            n = n * 3 + 1
            k -= 1

        
    if k > 0 and n == 1:

        r = k % 3
        if r == 0:
            n = 1

        elif r == 1:
            n = 4

        else:
            n =2
    print(n)


if __name__ == "__main__":

    main()
        




